app.controller("myorders2", function ($scope, $http) {
    var token = localStorage.getItem('token');
    $scope.allOrderInfo =[];

    //查看所有未支付订单
    $scope.willBuyOrders = function () {
        $.showPreloader('请稍候');
        if (!token) {
            $.toast("请先登录");
            location.href = '#user-login';
            return;
        }
        if (token) {
            $http({
                method: 'get',
                url: app.netPath + '/order/show/listorder',
                headers: {Authorization: token},
                params:{orderStatus:1}
            }).then(function (res) {
                $.hidePreloader();
                console.log(res.data);
                if (!res.data.error) {

                    //没有订单
                    if(res.data.data==undefined){

                        $scope.noOrder='暂无订单';
                        $scope.allOrderInfoCount=0;
                        return;

                    }

                    $scope.allOrderInfo= res.data.data;

                    for(var i=0;i<$scope.allOrderInfo.length;i++){
                        $scope.allOrderInfo[i].aClass.classImg=app.netPath + '/resources/classImg/'+$scope.allOrderInfo[i].aClass.classImg;
                        app.buildImageUrl($scope.allOrderInfo[i].aClass,'classImg',function () {
                            $scope.$digest();
                        });
                    }


                }
                else {


                }

            },function(){
                $.hidePreloader();
                $.toast('网络走丢了！')
            })
        }
    };


    $scope.getOrderId=function(orderId){
        sessionStorage.setItem('orderId',orderId);
        location.href='#confirm-order';
    };
});